import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import iView from 'iview'
import i18n from '@/locale'
import { config } from '@/config'
import jquery from 'jquery'
import 'iview/dist/styles/iview.css'

// 引入iView
Vue.use(iView, {
  i18n: function (path, options) {
    const value = i18n.t(path, options)
    if (value !== null && value !== undefined) {
      return value
    }
    return ''
  }
})
/**
 * @description 全局注册应用配置
 */
Vue.prototype.$config = config
Vue.prototype.$jquery = jquery

router.beforeEach((to, from, next) => {
  iView.LoadingBar.start()
  next()
})
router.afterEach(to => {
  iView.LoadingBar.finish()
  window.scrollTo(0, 0)
})

// 阻止 vue 在启动时生成生产提示
Vue.config.productionTip = false
new Vue({
  router,
  store,
  i18n,
  render: h => h(App)
}).$mount('#app')
